package com.example.processor

// DSL 主类
class CrudDsl {
    private val entities = mutableListOf<EntityConfig>()

    // 定义实体配置
    fun entity(className: String, block: EntityConfig.() -> Unit = {}) {
        val config = EntityConfig(className).apply(block)
        entities.add(config)
    }

    // 构建最终配置列表
    fun build(): List<EntityConfig> = entities.toList()

    // 实体配置类
    class EntityConfig(val className: String) {
        // 默认基础路径为 /api/类名小写
        var basePath: String = "/${className.substringAfterLast('.').lowercase()}"
        var apiTag = ""

    }
}

// DSL 入口函数
fun crudConfig(block: CrudDsl.() -> Unit): List<CrudDsl.EntityConfig> {
    return CrudDsl().apply(block).build()
}